#ifndef __COMMON_HPP__
#define __COMMON_HPP__

#define KB 1024       // 2^10
#define MB 1048576    // 2^20
#define GB 1073741824 // 2^30

#define UDP_RECV_MAX 10240
#define TCP_RECV_MAX 10240
// 定义 container_of 宏
#define container_of(ptr, type, member) ({                      \
	const decltype( ((type *)0)->member ) *__mptr = (ptr);    \
	(type *)( (char *)__mptr - offsetof(type,member) );})

bool net_optimize_setReceiveBuffer(int fd, size_t _size);
int create_bind_net_socket(int __type, const char* ip, int port);
int setnonblocking(int fd) ;
void create_directory(const char *directory_path);
/* 设置 TCP 关闭 Nagle算法 */
bool net_optimize_disable_Nagle(int fd);
/* 设置TCP 快速ACK 需要每次recv 后设置 */
bool net_optimize_enableQuickAck(int fd);
uint64_t BytesStringToBytes(const char *size_str);
void dump_hex(const uint8_t *buf, uint32_t size, uint32_t number);
int is_tcpdump_data(const char *data, size_t len);

#endif /*__COMMON_HPP__ */
